package com.tianji;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@MapperScan("com.tianji.*.mapper")
@EnableAsync//开启异步线程池
@Slf4j
@EnableAspectJAutoProxy(exposeProxy = true)//开启代理模式
public class TianjixuetangApplication {

    public static void main(String[] args) throws UnknownHostException {
        SpringApplication app = new SpringApplicationBuilder(TianjixuetangApplication.class).build(args);
        ConfigurableEnvironment env = app.run(args).getEnvironment();
        String protocal = "http";
        if(env.getProperty("server.ssl.key-store") != null) {
            protocal = "https";
        }
        log.info("--/\n-------------------------------------------------------------------" +
                "Application'{}' is running Acccess URLs:\n\t"+
                "Local: \t\t{}://localhost:{}\n\t"+
                "External: \t{}://{}:{}\n\t"+
                "Profile(s): \t{}\n\t"+
                "swagger: {}://localhost:{}/swagger-ui/\n\t"+
                "\n-------------------------------------------------------------------------",
                env.getProperty("spring.application.name"),
                protocal,
                env.getProperty("server.port"),
                protocal,
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                env.getActiveProfiles(),
                protocal,
                env.getProperty("server.port")
        );
    }

}
